﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Booking_Hotel.DBML;

namespace Booking_Hotel.DAL
{
    public class Supplier_HotelDAO
    {
        ThanhBHotelDataContext sdb = new ThanhBHotelDataContext();

        public Supplier_Hotel GetSupplier_HotelByID(int ID)
        {
            return sdb.sp_Supplier_Hotel_Select(ID).SingleOrDefault();
        }

        public void addSupplier_Hotel(Supplier_Hotel sh)
        {
            Supplier_Hotel add = new Supplier_Hotel
            {

                SupplierID = sh.SupplierID,
                TenKhachSan= sh.TenKhachSan,
                DiaChiKhachSan= sh.DiaChiKhachSan,
                TieuChuanSao= sh.TieuChuanSao,
                Description= sh.Description

            };
            sdb.Supplier_Hotels.InsertOnSubmit(add);
            sdb.SubmitChanges();
        }

        public void updateSupplier_Hotel(Supplier_Hotel sh)
        {
            Supplier_Hotel update = sdb.Supplier_Hotels.Single(ca => ca.Supplier_HotelID == (int)sh.Supplier_HotelID);
            {
                update.Supplier_HotelID = sh.Supplier_HotelID;
                update.TenKhachSan = sh.TenKhachSan;
                update.DiaChiKhachSan = sh.DiaChiKhachSan;
                update.TieuChuanSao = sh.TieuChuanSao;
                update.Description = sh.Description;
            }
            sdb.SubmitChanges();
        }
    }
}